package com.test.utils;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
/**
 * turn a file into byte array;
 * @author Administrator
 *
 */
public class BinaryFile {
	public static byte[] read(File bFile) throws IOException {
		BufferedInputStream bf = new BufferedInputStream(new FileInputStream(
				bFile));
		try {
			byte[] data = new byte[bf.available()];
			// Reads some number of bytes from the input stream and stores them
			// into the buffer array data.
			bf.read(data);
			return data;
		} finally {
			bf.close();
			
		}
	}

	public static byte[] read(String bFile) throws IOException {
		return read(new File(bFile).getAbsoluteFile());
	}
}
